<%@ page import="com.cgah.Constants" %>
<%--
  Created by IntelliJ IDEA.
  User: chue
  Date: 4/30/11
  Time: 12:40 PM
  To change this template use File | Settings | File Templates.
--%>
<sec:ifLoggedIn>
%{--NOTE: admin cannot also be a user--}%
    <g:if test="${showAdmin == 1}">
        <sec:ifAllGranted roles="${Constants.ROLE_ADMIN}">
            <div class="buttons">
                <g:form>
                    <g:hiddenField name="id" value="${targetId}"/>
                    <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}"/></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"/></span>
                </g:form>
            </div>
        </sec:ifAllGranted>
    </g:if>
    <g:else>
        <sec:ifAllGranted roles="${Constants.ROLE_USER}">
            <g:if test="${customerId == applicationContext.springSecurityService.currentUser.id}">
                <div class="buttons">
                    <g:form>
                        <g:hiddenField name="id" value="${targetId}"/>
                        <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}"/></span>
                        <span class="button"><g:actionSubmit class="delete" action="delete"
                                value="${message(code: 'default.button.delete.label', default: 'Delete')}"
                                onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"/></span>
                    </g:form>
                </div>
            </g:if>

        </sec:ifAllGranted>
    </g:else>
</sec:ifLoggedIn>
